package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.hqfinance.domain.HqNewSalesmanSheet;
import com.ruoyi.hqfinance.domain.HqPaiFeeThroughSheetByNet;
import com.ruoyi.hqfinance.domain.HqPaiFeeThroughSheetByNetAndArea;
import com.ruoyi.hqfinance.domain.HqPaiFeeThroughSheetByNetAndAreaAndSalesman;
import com.ruoyi.hqfinance.domain.vo.HqNewSalesmanSheetVo;
import com.ruoyi.hqfinance.domain.vo.HqPaiFeeThroughSheetVo;
import com.ruoyi.hqfinance.service.HqNewSalesmanSheetService;
import com.ruoyi.hqfinance.service.HqPaiFeeThroughSheetService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hq/newSalesman")
@Api(tags = "总部财务-新业务员报表")
public class HqNewSalesmanSheetController {
    @Autowired
    private HqNewSalesmanSheetService hqNewSalesmanSheetService;
    @Autowired
    private HqPaiFeeThroughSheetService hqPaiFeeThroughSheetService;
    @ApiOperation("业务员账单报表")
    @PostMapping("/newSalesmanSheet")
    public R newSalesmanSheet(@RequestBody HqNewSalesmanSheetVo vo){
        List<HqNewSalesmanSheet> newSalesmanSheets = hqNewSalesmanSheetService.newSalesmanSheet(vo);
        if (newSalesmanSheets == null || newSalesmanSheets.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(newSalesmanSheets));
        }
    }

    @ApiOperation("网点派费直达报表-网点汇总")
    @PostMapping("/collectA")
    public R collectByNetwork(@RequestBody HqPaiFeeThroughSheetVo vo){
        List<HqPaiFeeThroughSheetByNet> paiFeeThroughSheets = hqPaiFeeThroughSheetService.collectA(vo);
        if (paiFeeThroughSheets == null || paiFeeThroughSheets.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(paiFeeThroughSheets));
        }
    }
    @ApiOperation("网点派费直达报表-网点+承包区汇总")
    @PostMapping("/collectB")
    public R collectByNetworkAndArea(@RequestBody HqPaiFeeThroughSheetVo vo){
        List<HqPaiFeeThroughSheetByNetAndArea> paiFeeThroughSheets = hqPaiFeeThroughSheetService.collectB(vo);
        if (paiFeeThroughSheets == null || paiFeeThroughSheets.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(paiFeeThroughSheets));
        }
    }
    @ApiOperation("网点派费直达报表-网点+承包区+业务员汇总")
    @PostMapping("/collectC")
    public R collectByNetworkAndAreaAndSalesman(@RequestBody HqPaiFeeThroughSheetVo vo){
        List<HqPaiFeeThroughSheetByNetAndAreaAndSalesman> paiFeeThroughSheets = hqPaiFeeThroughSheetService.collectC(vo);
        if (paiFeeThroughSheets == null || paiFeeThroughSheets.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(paiFeeThroughSheets));
        }
    }


}
